package com.Jhu1.test;

import com.Jhu1.entity.Student;
import com.Jhu1.service.IStudentService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class test_first {
    @Autowired
    private IStudentService studentService;

    @Test
    public void test() {
        List<Student> list = studentService.list();
        list.forEach(student -> {
            System.out.println("ID: " + student.getCid() + ", Name: " + student.getCname()
        );
    });
    }

    @Test
    public void test2() {
        Student student = new Student();
        student.setSname("老六");
        student.setSex("女");
        student.setAddress("广东");
        student.setCid(210451);
        studentService.save(student);
    }
    @Test
    public void test3() {
        Integer sid = 1;
        Student student = studentService.getById(sid);
        student.setSname("楚少");
        student.setAddress("上海市");
        studentService.updateById(student);
    }
}
